<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/meta.jsp"%>
<title>职位管理</title>
</head>
<body>

	<%@include file="/common/header.jsp"%>
	
	<div id="jobGrid"></div>
	
	<%@include file="/common/footer.jsp"%>
	
	<script type="text/javascript">
		$(function() {
			$("#jobGrid").flexigrid({
				title: "职位信息列表",
				url: "<c:url value='/pf/job/dataGrid'/>",
				colModel: [
					{display: "职位名称", name: "jobName"},
					{display: "备注", name: "jobMemo",align: "left",width:200},
					{display: "排序值", name: "jobOrderno"},
					{display: "是否有效", name: "jobIsvalid"}
				],
				buttons: [
					{name: "新增", bclass: "add", onpress: btns},
					{separator: true},
					{name: "修改", bclass: "modify", onpress: btns},          
					{separator: true},
					{name: "删除", bclass: "delete", onpress: btns},
					{separator: true}
				],
				usepager: true,
				height:$(window).height()-210
			});
		});
		
		//操作
		function btns(com, grid) {
			if("新增" == com) {
				art.dialog.open(
					"<c:url value='/pf/job/faJob'/>", 
					{
						id: "addJob",
						title: "增加职位",
						lock: true,
						width: 300,
						height: 300
					}
				);
			} else if($(".trSelected", grid).length == 1) {
				var id = $(".trSelected", grid).attr("id").replace("row", "");
				if("修改" == com) {
					art.dialog.open(
						"<c:url value='/pf/job/fmJob?jobId=" + id + "'/>", 
						{
							id: "modifyJob",
							title: "修改职位",
							lock: true,
							width: 300,
							height: 300
						}
					);
				} else if("删除" == com) {
					$.post(
						"<c:url value='/pf/job/dJob'/>",
						{"jobId": id},
						function(data, status) {
							if("success" == status) {
								$("#jobGrid").flexReload();
							} else {
								art.dialog.alert(data.msg);
							}
						}
					);
				}
			} else {
				art.dialog.alert("请选择要" + com + "的职位！");
			}
		}
		
		//刷新页面
		function closeAndRefresh() {
			$("#jobGrid").flexReload();
			
			$.each(art.dialog.list, function(i, n) {
				art.dialog.list[i].close();
			});
		}
	</script>
</body>
</html>